package com.hk.yajin.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.hk.yajin.R;

/**
 * 弹出菜单
 *
 * @author wl
 */
public class PopupWindows extends PopupWindow {

    public PopupWindows(Context context, String tip, float goldNum, View parent, final PopOnClickListener listener) {
        View view = View.inflate(context, R.layout.buy_video_pop, null);
        setWidth(LayoutParams.MATCH_PARENT);
        setHeight(LayoutParams.MATCH_PARENT);
        setBackgroundDrawable(new BitmapDrawable(null, (Bitmap) null));
        setFocusable(true);
        setOutsideTouchable(true);
        setAnimationStyle(R.style.popupAnimation);
        setContentView(view);
        showAtLocation(parent, Gravity.BOTTOM, 0, 0);
        update();

        TextView tv_yes = (TextView) view.findViewById(R.id.tv_yes);
        TextView tv_no = (TextView) view.findViewById(R.id.tv_no);
        TextView tv_gold = (TextView) view.findViewById(R.id.tv_gold);
        TextView tv_tip = (TextView) view.findViewById(R.id.tv_tip);

        tv_tip.setText(tip);
        tv_gold.setText(goldNum + context.getString(R.string.gold));

        tv_yes.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onClickYes();
                dismiss();
            }
        });
        tv_no.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onClickNo();
                dismiss();
            }
        });


    }

    public interface PopOnClickListener {
        void onClickYes();

        void onClickNo();

    }
}